#https://leetcode.cn/problems/minimum-size-subarray-sum/solutions/2673056/hua-dong-chuang-kou-ben-zhi-tong-xiang-s-zc1x/

class Solution {
public:
    int minSubArrayLen(int target, vector<int>& nums) {
        int len=INT_MAX,n=nums.size();
        int sum=0;
        for(int left=0,right=0;right<n;right++){
            sum+=nums[right];
            while(sum>=target){
                len=min(len,right-left+1);
                sum-=nums[left];
                left++;
            }
        }
        return len ==INT_MAX? 0 : len;
    }
};